<template>
  <div class="tablewrap">
    <div>当前可参加的活动</div>
    <FilterTable
      :isColumnFilter="false"
      :columns="columns"
      :dataSource="dataSource"
      :height="200"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="rowSelectChange"
    ></FilterTable>
  </div>
</template>

<script>
import moment from 'moment';
import { queryActivityValid } from '@/api/repair/repairReception/customer/monitoring.js';
import { dictionary } from '@/utils/dictMixin';
export default {
  name: 'HuoDong0',
  mixins: [dictionary],
  props: {
    queryParams: Object
  },
  data() {
    return {
      // 活动 可选的
      columns: this.createColumnsActivitiesOptional(),
      dataSource: [],
      selectRow: []
    };
  },
  mounted() {
    this.queryActivityValid();
  },
  methods: {
    rowSelectChange(opt) {
      console.log(opt);
      this.selectRow = opt;
      this.$emit('selectChange', opt);
    },
    // 查询可选活动
    async queryActivityValid() {
      const params = {
        sort: 'ACTIVITY_CODE',
        order: 'asc',
        ...this.queryParams
        // LICENSE: '陕A2FU00',
        // vin: '09876543219876543',
        // ownerNo: 'OW1907110001',
        // BRAND: 'LINCOLN',
        // MILEAGE: '999999',
        // isRepairOrder: 'REPAIR_ORDER_TAG',
        // dmsFuncId: '35100010',
        // createDate: moment().format('YYYY-MM-DD HH-mm'), //'2019-08-14 20:20',
        // _: moment().valueOf()
      };
      const res = await queryActivityValid(params);
      console.log('查询可选活动', params, res);
      this.dataSource = res.data;
    },
    // 活动 可选的
    createColumnsActivitiesOptional() {
      return [
        {
          title: '序号',
          width: 50,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        {
          title: '活动编号',
          dataIndex: 'ACTIVITY_CODE'
        },
        {
          title: '活动名称',
          dataIndex: 'ACTIVITY_NAME'
        },
        {
          title: '活动类型',
          dataIndex: 'ACTIVITY_TYPE',
          render: props => {
            return <span>{this.createDictText(props.row.ACTIVITY_TYPE, '8080')}</span>;
          }
        },
        {
          title: '开始日期',
          dataIndex: 'BEGIN_DATE'
        },
        {
          title: '结束日期',
          dataIndex: 'END_DATE'
        },
        {
          title: '活动总金额',
          dataIndex: 'ACTIVITY_AMOUNT'
        }
      ];
    }
  }
};
</script>

<style scoped></style>
